var testData = Array.from({length: 5000}, () => Math.round(Math.random() * 10) )

var tmp = testData.sort()
var res = [tmp[0]]

for (let i = 0; i<tmp.length; i++) {
    if (tmp[i] !== tmp[i+1]) {
        res.push(tmp[i])
    }
}

console.log(res)